package com.clayecloud.common.admin.controller;

import com.clayecloud.common.admin.services.HouseService;
import com.clayecloud.common.entity.House;
import com.clayecloud.common.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ClayeLink
 * @date 2022/1/3 18:58
 */
@RestController
@RequestMapping("/admin/house")
@Api(tags = "房屋管理模块")
public class AdminHouseController {

    @Resource
    private HouseService houseService;

    @GetMapping("/all")
    @ApiOperation("获取房屋数据根据大小和页码")
    public MessageUtil getAllHouse(Integer size, Integer page){
        return houseService.selectAll(size, page);
    }

    @DeleteMapping("/delete")
    @ApiOperation("根据id删除房屋数据")
    public MessageUtil deleteHouseByID(Integer houseID){
        return houseService.deleteByPrimaryKey(houseID);
    }

    @PutMapping("/update")
    @ApiOperation("更新房屋数据")
    public MessageUtil updateHouse(House house){
        return houseService.updateByPrimaryKeySelective(house);
    }

}
